package com.ve.searcher

import com.ve.searcher.service.LuceneService
import org.appsugar.archetypes.extension.getLogger
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean

@SpringBootApplication
class MainApplication{
    @Autowired
    var luncfg: MyConfigurationProperties ?= null


    @Bean
    fun commandLineRunner(ctx: ApplicationContext, luceneService:LuceneService): CommandLineRunner {
        return CommandLineRunner {
            getLogger<MainApplication>().error("fileindex: ${luncfg!!.fileindex}")
            getLogger<MainApplication>().error("searchpath: ${luncfg!!.searchpath}")
            luceneService.init()
        }
    }
}

fun main(args: Array<String>) {
    runApplication<MainApplication>(*args)
}